home *** CD-ROM | disk | FTP | other *** search
/ CD ROM Paradise Collection 4 / CD ROM Paradise Collection 4 1995 Nov.iso / science / sm32a.zip / LIBRARY / DATAPLOT.LI3 < prev    next >
Text File  |  1993-12-23  |  779b  |  33 lines

  1. #    dataplot() plots data ( [x1,x2,...], [y1,y2,...] ) on xy-plane
  2. #    e.g.    dataplot([1,2,3], [1,4,9])
  3.  
  4. dataplot(x_, y_) := block(numeric:=on,
  5.     graph,
  6.     xmax:=max(x),
  7.     xmin:=min(x),
  8.     ymax:=max(y),
  9.     ymin:=min(y),
  10.     getmaxy3:=getmaxy-30,
  11.     getmaxy2:=getmaxy3+1,
  12.     dx:=(xmax-xmin)/(getmaxx-40),
  13.     dy:=(ymax-ymin)/(getmaxy-30),
  14.     length:=length(y),
  15.     line(40,getmaxy3,getmaxx,getmaxy3),
  16.     line(40,0,40,getmaxy3),
  17.     moveto(0,0),
  18.     writes(ymax),
  19.     moveto(0,getmaxy3),
  20.     writes(ymin),
  21.     moveto(35,getmaxy-20),
  22.     writes(xmin),
  23.     moveto(getmaxx-30,getmaxy-20),
  24.     writes(xmax),
  25.     setviewport(40,0,getmaxx,getmaxy3,1),
  26.     moveto(0,getmaxy3),
  27.     do( lineto((member(x,j)-xmin)/dx,getmaxy2-(member(y,j)-ymin)/dy),
  28.     j,1,length,1),
  29.     numeric:=off,
  30.     readchar,
  31.     text,
  32.     local(dx,dy,length))
  33.